package com.chen.dao;

import com.chen.entity.Fan;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.common.Mapper;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;

public interface FanMapper extends Mapper<Fan> {

    @Select({"<script>",
            "SELECT ",
            "  f.id as fid,",
            "  t.`id` AS ftid,",
            "  f.`fcode`,",
            "  DATE_FORMAT(f.`create_time`, '%Y/%m/%d %H:%i:%s') AS create_time,",
            "  f.`state`,",
            "  f.`remark`,",
            "  p.`pname`,",
            "  f.`is_con_net`,",
            "  p.id AS pid,",
            "   IFNULL( DATE_FORMAT(t.`bwsj`, '%Y/%m/%d') ,'-')  AS bwsj,",
            "   IFNULL( DATE_FORMAT(t.`sjsj`, '%Y/%m/%d') ,'-')  AS sjsj,",
            "   IFNULL( DATE_FORMAT(t.`qnjsj`, '%Y/%m/%d'),'-')  AS qnjsj,",
            "   IFNULL( DATE_FORMAT(t.`bnjsj`, '%Y/%m/%d'),'-')  AS bnjsj,",
            "   IFNULL( DATE_FORMAT(t.`xjsj`, '%Y/%m/%d') ,'-')  AS xjsj,",
            "   IFNULL( DATE_FORMAT(t.`yjxcbnjsj`, '%Y/%m/%d' ),'-')AS yjxcbnjsj,",
            "   IFNULL( DATE_FORMAT(t.`yjxcqnjsj`, '%Y/%m/%d' ),'-')AS yjxcqnjsj,",
            "   IFNULL( DATE_FORMAT(t.`yjxcxjsj`, '%Y/%m/%d'  ),'-')AS yjxcxjsj ",
            "FROM",
            "  tb_fan f ",
            "  INNER JOIN tb_project p ",
            "    ON f.`attr_project_id` = p.id ",
            "  INNER JOIN `tb_fans_testingtime` t ",
            "    ON f.id = t.`fanid` ",

            " where f.create_user_id = #{uid} ",
            "<if test='fjbh != null and  fjbh !=  \"\" '>",
            " and f.`fcode` = #{fjbh}",
            "</if>",

            "<if test='projectid != null and  projectid !=  \"\" '>",
            " and p.`id` = #{projectid}",
            "</if>",

            "<if test='btime != null and  btime !=  \"\" '>",
            " and  LEFT(t.`create_time`,8) <![CDATA[ >= ]]> #{btime}",
            "</if>",


            "<if test='etime != null and  etime !=  \"\" '>",
            " and   LEFT(t.`create_time`,8) <![CDATA[ <= ]]> #{etime}",
            "</if>",

            " ORDER BY CAST( SUBSTR( f.fcode, '1', LOCATE('#', f.fcode) - 1 ) AS SIGNED) ",
            "</script>"})
        //主页查询全部风机数据
    List<LinkedHashMap> queryFans(@Param("fjbh") String fjbh,
                                  @Param("projectid") String projectid,
                                  @Param("btime") String btime,
                                  @Param("etime") String etime,
                                  @Param("uid") String uid);


    @Select("SELECT COUNT(1) FROM  `tb_fan` t WHERE  t.`fcode` = #{fcode} and t.`attr_project_id`  = #{attrProjectId} ")
    int queryFanNumByFcode(@Param("fcode") String fcode, @Param("attrProjectId") String attrProjectId);


    @Select({"<script>", "SELECT ",
            "  f.id AS fid,",
            "  t.`id` AS ftid,",
            "  f.`fcode`,",
            "  f.`remark`,",
            "  p.id AS attrProjectId,",
            "  IFNULL(DATE_FORMAT(t.`bwsj`, '%Y/%m/%d') ,'') AS bwsj,",
            "  IFNULL(DATE_FORMAT(t.`sjsj`, '%Y/%m/%d') ,'') AS sjsj,",
            "  IFNULL(DATE_FORMAT(t.`qnjsj`, '%Y/%m/%d'),'') AS qnjsj,",
            "  IFNULL(DATE_FORMAT(t.`bnjsj`, '%Y/%m/%d'),'') AS bnjsj,",
            "  IFNULL(DATE_FORMAT(t.`xjsj`, '%Y/%m/%d'),'') AS xjsj,",
            "  IFNULL(DATE_FORMAT(t.`yjxcbnjsj`, '%Y/%m/%d'),'') AS xcbnjsj,",
            "  IFNULL(DATE_FORMAT(t.`yjxcqnjsj`, '%Y/%m/%d'),'') AS xcqnjsj,",
            "  IFNULL(DATE_FORMAT(t.`yjxcxjsj`, '%Y/%m/%d'),'') AS xcxjsj ",
            "FROM",
            "  tb_fan f ",
            "  INNER JOIN tb_project p ",
            "    ON f.`attr_project_id` = p.id ",
            "  INNER JOIN `tb_fans_testingtime` t ",
            "    ON f.id = t.`fanid` ",
            "WHERE f.id = #{fid} ",
            "</script>"})
    HashMap queryFensById(@Param("fid") String fid);


    @Select("SELECT * FROM `tb_fan`  t WHERE   t.`attr_project_id` = #{pid} ")
    List<Fan> queryFansByProjectId(@Param("pid") String pid);


    @Select({"<script>",
            "SELECT  " +
                    "  yuqi_mes.*  " +
                    "FROM " +
                    "  (SELECT  " +
                    "    tp.`id` AS pid, " +
                    "    tp.`pname` pname, " +
                    "    tf.`id` AS fid, " +
                    "    tf.`fcode` AS fcode, " +
                    "     DATE_FORMAT(tft.`yjxcqnjsj`,'%Y/%m/%d')  AS yjqnjsj , " +
                    "     DATE_FORMAT(tft.`yjxcbnjsj`,'%Y/%m/%d')  AS yjbnjsj , " +
                    "     DATE_FORMAT(tft.`yjxcxjsj`  ,'%Y/%m/%d') AS yjxjsj  , " +
                    "    IFNULL( " +
                    "      ( " +
                    "        CASE " +
                    "          WHEN ( " +
                    "            DATE_FORMAT(CURDATE(), '%Y%m%d') > tft.`yjxcqnjsj` " +
                    "          )  " +
                    "          THEN DATEDIFF( " +
                    "            CURDATE(), " +
                    "            ( " +
                    "              DATE_FORMAT(tft.`yjxcqnjsj`, '%Y-%m-%d') " +
                    "            ) " +
                    "          )  " +
                    "          ELSE '未逾期'  " +
                    "        END " +
                    "      ), " +
                    "      '-' " +
                    "    ) AS qnjyqsj, " +
                    "    IFNULL( " +
                    "      ( " +
                    "        CASE " +
                    "          WHEN ( " +
                    "            DATE_FORMAT(CURDATE(), '%Y%m%d') > tft.`yjxcbnjsj` " +
                    "          )  " +
                    "          THEN DATEDIFF( " +
                    "            CURDATE(), " +
                    "            ( " +
                    "              DATE_FORMAT(tft.`yjxcbnjsj`, '%Y-%m-%d') " +
                    "            ) " +
                    "          )  " +
                    "          ELSE '未逾期'  " +
                    "        END " +
                    "      ), " +
                    "      '-' " +
                    "    ) AS bnjyqsj, " +
                    "    IFNULL( " +
                    "      ( " +
                    "        CASE " +
                    "          WHEN ( " +
                    "            DATE_FORMAT(CURDATE(), '%Y%m%d') > tft.`yjxcxjsj` " +
                    "          )  " +
                    "          THEN DATEDIFF( " +
                    "            CURDATE(), " +
                    "            ( " +
                    "              DATE_FORMAT(tft.`yjxcxjsj`, '%Y-%m-%d') " +
                    "            ) " +
                    "          )  " +
                    "          ELSE '未逾期'  " +
                    "        END " +
                    "      ), " +
                    "      '-' " +
                    "    ) AS xjyqsj  " +
                    "  FROM " +
                    "    ( " +
                    "      `tb_fan` tf  " +
                    "      JOIN `tb_fans_testingtime` tft  " +
                    "        ON tf.`id` = tft.`fanid` " +
                    "    )  " +
                    "    JOIN `tb_project` tp  " +
                    "      ON tf.`attr_project_id` = tp.`id`) AS yuqi_mes  " +
                    "WHERE yuqi_mes.pid = #{pid}  " +
                    "  AND NOT ( " +
                    "    yuqi_mes.qnjyqsj = '未逾期'  " +
                    "    AND yuqi_mes.bnjyqsj = '未逾期'  " +
                    "    AND yuqi_mes.xjyqsj = '未逾期' " +
                    "  )  " +
                    "  AND NOT (yuqi_mes.qnjyqsj = '-')  " +

                    //动态替换的过滤条件
                    "<if test='queryStr != null and  queryStr !=  \"\" '>",
            "${queryStr}",
            "</if>",

            " ORDER BY   CAST( SUBSTR( yuqi_mes.fcode, '1', LOCATE('#', yuqi_mes.fcode) - 1 ) AS SIGNED)  ",

            "</script>"})
        //查看已经逾期风机信息
    List<LinkedHashMap> queryYqFansByPid(@Param("pid") String pid, @Param("queryStr") String queryStr);


    @Select({"<script>",
            "SELECT  " +
                    "yuqi_mes.pname," +
                    "  yuqi_mes.fcode," +
                    "  yuqi_mes.yjqnjsj," +
                    "  yuqi_mes.qnjyqsj," +
                    "  yuqi_mes.yjbnjsj," +
                    "  yuqi_mes.bnjyqsj," +
                    "  yuqi_mes.yjxjsj," +
                    "  yuqi_mes.xjyqsj " +
                    "FROM " +
                    "  (SELECT  " +
                    "    tp.`id` AS pid, " +
                    "    tp.`pname` pname, " +
                    "    tf.`id` AS fid, " +
                    "    tf.`fcode` AS fcode, " +
                    "     DATE_FORMAT(tft.`yjxcqnjsj`,'%Y/%m/%d')  AS yjqnjsj , " +
                    "     DATE_FORMAT(tft.`yjxcbnjsj`,'%Y/%m/%d')  AS yjbnjsj , " +
                    "     DATE_FORMAT(tft.`yjxcxjsj`  ,'%Y/%m/%d') AS yjxjsj  , " +
                    "    IFNULL( " +
                    "      ( " +
                    "        CASE " +
                    "          WHEN ( " +
                    "            DATE_FORMAT(CURDATE(), '%Y%m%d') > tft.`yjxcqnjsj` " +
                    "          )  " +
                    "          THEN DATEDIFF( " +
                    "            CURDATE(), " +
                    "            ( " +
                    "              DATE_FORMAT(tft.`yjxcqnjsj`, '%Y-%m-%d') " +
                    "            ) " +
                    "          )  " +
                    "          ELSE '未逾期'  " +
                    "        END " +
                    "      ), " +
                    "      '-' " +
                    "    ) AS qnjyqsj, " +
                    "    IFNULL( " +
                    "      ( " +
                    "        CASE " +
                    "          WHEN ( " +
                    "            DATE_FORMAT(CURDATE(), '%Y%m%d') > tft.`yjxcbnjsj` " +
                    "          )  " +
                    "          THEN DATEDIFF( " +
                    "            CURDATE(), " +
                    "            ( " +
                    "              DATE_FORMAT(tft.`yjxcbnjsj`, '%Y-%m-%d') " +
                    "            ) " +
                    "          )  " +
                    "          ELSE '未逾期'  " +
                    "        END " +
                    "      ), " +
                    "      '-' " +
                    "    ) AS bnjyqsj, " +
                    "    IFNULL( " +
                    "      ( " +
                    "        CASE " +
                    "          WHEN ( " +
                    "            DATE_FORMAT(CURDATE(), '%Y%m%d') > tft.`yjxcxjsj` " +
                    "          )  " +
                    "          THEN DATEDIFF( " +
                    "            CURDATE(), " +
                    "            ( " +
                    "              DATE_FORMAT(tft.`yjxcxjsj`, '%Y-%m-%d') " +
                    "            ) " +
                    "          )  " +
                    "          ELSE '未逾期'  " +
                    "        END " +
                    "      ), " +
                    "      '-' " +
                    "    ) AS xjyqsj  " +
                    "  FROM " +
                    "    ( " +
                    "      `tb_fan` tf  " +
                    "      JOIN `tb_fans_testingtime` tft  " +
                    "        ON tf.`id` = tft.`fanid` " +
                    "    )  " +
                    "    JOIN `tb_project` tp  " +
                    "      ON tf.`attr_project_id` = tp.`id`) AS yuqi_mes  " +
                    "WHERE yuqi_mes.pid = #{pid}  " +
                    "  AND NOT ( " +
                    "    yuqi_mes.qnjyqsj = '未逾期'  " +
                    "    AND yuqi_mes.bnjyqsj = '未逾期'  " +
                    "    AND yuqi_mes.xjyqsj = '未逾期' " +
                    "  )  " +
                    "  AND NOT (yuqi_mes.qnjyqsj = '-')  " +

                    //动态替换的过滤条件
                    "<if test='queryStr != null and  queryStr !=  \"\" '>",
            "${queryStr}",
            "</if>",

            " ORDER BY   CAST( SUBSTR( yuqi_mes.fcode, '1', LOCATE('#', yuqi_mes.fcode) - 1 ) AS SIGNED)  ",

            "</script>"})
    List<LinkedHashMap> queryYqFansForDownExcel(@Param("pid") String pid, @Param("queryStr") String queryStr);


    @Select({"<script>" +
            "SELECT  " +
            "  jijiangyuqi_mes.*  " +
            "FROM " +
            "  (SELECT  " +
            "    tp.`id` AS pid, " +
            "    tp.`pname` AS pname, " +
            "    tf.`fcode` AS fcode, " +
            "    tf.`id` AS fid, " +
            "    DATE_FORMAT(tft.`yjxcqnjsj`,'%Y/%m/%d')  AS yjqnjsj , " +
            "    DATE_FORMAT(tft.`yjxcbnjsj`,'%Y/%m/%d')  AS yjbnjsj , " +
            "    DATE_FORMAT(tft.`yjxcxjsj`  ,'%Y/%m/%d') AS yjxjsj  , " +
            "    IFNULL( " +
            "      ( " +
            "        CASE " +
            "          WHEN ( " +
            "            DATE_FORMAT(CURDATE(), '%Y%m%d')  <![CDATA[ <= ]]>  tft.`yjxcqnjsj` " +
            "          )  " +
            "          THEN DATEDIFF( " +
            "            DATE_FORMAT(tft.`yjxcqnjsj`, '%Y-%m-%d'), " +
            "            CURDATE() " +
            "          )  " +
            "          ELSE CONCAT( " +
            "            '逾期', " +
            "            DATEDIFF( " +
            "              CURDATE(), " +
            "              DATE_FORMAT(tft.`yjxcqnjsj`, '%Y-%m-%d') " +
            "            ), " +
            "            '天' " +
            "          )  " +
            "        END " +
            "      ), " +
            "      '-' " +
            "    ) AS jqnjdqsj, " +
            "    IFNULL( " +
            "      ( " +
            "        CASE " +
            "          WHEN ( " +
            "            DATE_FORMAT(CURDATE(), '%Y%m%d') <![CDATA[ <= ]]> tft.`yjxcbnjsj` " +
            "          )  " +
            "          THEN DATEDIFF( " +
            "            DATE_FORMAT(tft.`yjxcbnjsj`, '%Y-%m-%d'), " +
            "            CURDATE() " +
            "          )  " +
            "          ELSE CONCAT( " +
            "            '逾期', " +
            "            DATEDIFF( " +
            "              CURDATE(), " +
            "              ( " +
            "                DATE_FORMAT(tft.`yjxcbnjsj`, '%Y-%m-%d') " +
            "              ) " +
            "            ), " +
            "            '天' " +
            "          )  " +
            "        END " +
            "      ), " +
            "      '-' " +
            "    ) AS jbnjdqsj, " +
            "    IFNULL( " +
            "      ( " +
            "        CASE " +
            "          WHEN ( " +
            "            DATE_FORMAT(CURDATE(), '%Y%m%d') <![CDATA[ <= ]]> tft.`yjxcxjsj` " +
            "          )  " +
            "          THEN DATEDIFF( " +
            "            DATE_FORMAT(tft.`yjxcxjsj`, '%Y-%m-%d'), " +
            "            CURDATE() " +
            "          )  " +
            "          ELSE CONCAT( " +
            "            '逾期', " +
            "            DATEDIFF( " +
            "              CURDATE(), " +
            "              DATE_FORMAT(tft.`yjxcxjsj`, '%Y-%m-%d') " +
            "            ), " +
            "            '天' " +
            "          )  " +
            "        END " +
            "      ), " +
            "      '-' " +
            "    ) AS jxjdqsj  " +
            "  FROM " +
            "    ( " +
            "      `tb_fan` tf  " +
            "      JOIN `tb_fans_testingtime` tft  " +
            "        ON tf.`id` = tft.`fanid` " +
            "    )  " +
            "    JOIN `tb_project` tp  " +
            "      ON tf.`attr_project_id` = tp.`id`) AS jijiangyuqi_mes  " +
            "WHERE" +
            "  jijiangyuqi_mes.pid = #{pid}  " +
            "  AND NOT (jijiangyuqi_mes.jqnjdqsj = '-')  " +

            //动态替换的过滤条件
            "<if test='queryStr1 != null and  queryStr1 !=  \"\" '>",
            "${queryStr1}",
            "</if>",


            "<if test='queryStr2 != null and  queryStr2 !=  \"\" '>",
            "${queryStr2}",
            "</if>",

            "ORDER BY   CAST( SUBSTR( jijiangyuqi_mes.fcode, '1', LOCATE('#', jijiangyuqi_mes.fcode) - 1 ) AS SIGNED)  " +
                    "</script>"})
        //查看即将逾期的风机信息
    List<LinkedHashMap> queryJjYqFansByPid(@Param("pid") String pid, @Param("queryStr1") String queryStr1, @Param("queryStr2") String queryStr2);









    @Select({"<script>" +
            "SELECT  " +

            "  jijiangyuqi_mes.pname," +
            "  jijiangyuqi_mes.fcode," +
            "  jijiangyuqi_mes.yjqnjsj," +
            "  jijiangyuqi_mes.jqnjdqsj," +
            "  jijiangyuqi_mes.yjbnjsj," +
            "  jijiangyuqi_mes.jbnjdqsj," +
            "  jijiangyuqi_mes.yjxjsj," +
            "  jijiangyuqi_mes.jxjdqsj " + //距巡检到期时间

            "FROM " +
            "  (SELECT  " +
            "    tp.`id` AS pid, " +
            "    tp.`pname` AS pname, " +
            "    tf.`fcode` AS fcode, " +
            "    tf.`id` AS fid, " +
            "    DATE_FORMAT(tft.`yjxcqnjsj`,'%Y/%m/%d')  AS yjqnjsj , " +
            "    DATE_FORMAT(tft.`yjxcbnjsj`,'%Y/%m/%d')  AS yjbnjsj , " +
            "    DATE_FORMAT(tft.`yjxcxjsj`  ,'%Y/%m/%d') AS yjxjsj  , " +
            "    IFNULL( " +
            "      ( " +
            "        CASE " +
            "          WHEN ( " +
            "            DATE_FORMAT(CURDATE(), '%Y%m%d')  <![CDATA[ <= ]]>  tft.`yjxcqnjsj` " +
            "          )  " +
            "          THEN DATEDIFF( " +
            "            DATE_FORMAT(tft.`yjxcqnjsj`, '%Y-%m-%d'), " +
            "            CURDATE() " +
            "          )  " +
            "          ELSE CONCAT( " +
            "            '逾期', " +
            "            DATEDIFF( " +
            "              CURDATE(), " +
            "              DATE_FORMAT(tft.`yjxcqnjsj`, '%Y-%m-%d') " +
            "            ), " +
            "            '天' " +
            "          )  " +
            "        END " +
            "      ), " +
            "      '-' " +
            "    ) AS jqnjdqsj, " +
            "    IFNULL( " +
            "      ( " +
            "        CASE " +
            "          WHEN ( " +
            "            DATE_FORMAT(CURDATE(), '%Y%m%d') <![CDATA[ <= ]]> tft.`yjxcbnjsj` " +
            "          )  " +
            "          THEN DATEDIFF( " +
            "            DATE_FORMAT(tft.`yjxcbnjsj`, '%Y-%m-%d'), " +
            "            CURDATE() " +
            "          )  " +
            "          ELSE CONCAT( " +
            "            '逾期', " +
            "            DATEDIFF( " +
            "              CURDATE(), " +
            "              ( " +
            "                DATE_FORMAT(tft.`yjxcbnjsj`, '%Y-%m-%d') " +
            "              ) " +
            "            ), " +
            "            '天' " +
            "          )  " +
            "        END " +
            "      ), " +
            "      '-' " +
            "    ) AS jbnjdqsj, " +
            "    IFNULL( " +
            "      ( " +
            "        CASE " +
            "          WHEN ( " +
            "            DATE_FORMAT(CURDATE(), '%Y%m%d') <![CDATA[ <= ]]> tft.`yjxcxjsj` " +
            "          )  " +
            "          THEN DATEDIFF( " +
            "            DATE_FORMAT(tft.`yjxcxjsj`, '%Y-%m-%d'), " +
            "            CURDATE() " +
            "          )  " +
            "          ELSE CONCAT( " +
            "            '逾期', " +
            "            DATEDIFF( " +
            "              CURDATE(), " +
            "              DATE_FORMAT(tft.`yjxcxjsj`, '%Y-%m-%d') " +
            "            ), " +
            "            '天' " +
            "          )  " +
            "        END " +
            "      ), " +
            "      '-' " +
            "    ) AS jxjdqsj  " +
            "  FROM " +
            "    ( " +
            "      `tb_fan` tf  " +
            "      JOIN `tb_fans_testingtime` tft  " +
            "        ON tf.`id` = tft.`fanid` " +
            "    )  " +
            "    JOIN `tb_project` tp  " +
            "      ON tf.`attr_project_id` = tp.`id`) AS jijiangyuqi_mes  " +
            "WHERE" +
            "  jijiangyuqi_mes.pid = #{pid}  " +
            "  AND NOT (jijiangyuqi_mes.jqnjdqsj = '-')  " +

            //动态替换的过滤条件
            "<if test='queryStr1 != null and  queryStr1 !=  \"\" '>",
            "${queryStr1}",
            "</if>",


            "<if test='queryStr2 != null and  queryStr2 !=  \"\" '>",
            "${queryStr2}",
            "</if>",

            "ORDER BY   CAST( SUBSTR( jijiangyuqi_mes.fcode, '1', LOCATE('#', jijiangyuqi_mes.fcode) - 1 ) AS SIGNED)  " +
                    "</script>"})
        //查看即将逾期的风机信息
    List<LinkedHashMap> queryJjYqFansForDownExcel(@Param("pid") String pid, @Param("queryStr1") String queryStr1, @Param("queryStr2") String queryStr2);











    @Select({"<script>",
            "SELECT ",
            "  p.`pname`,",
            "  f.`fcode`,",
            "   IFNULL( DATE_FORMAT(t.`bwsj`, '%Y/%m/%d') ,'-')  AS bwsj,",
            "   IFNULL( DATE_FORMAT(t.`sjsj`, '%Y/%m/%d') ,'-')  AS sjsj,",
            "   IFNULL( DATE_FORMAT(t.`qnjsj`, '%Y/%m/%d'),'-')  AS qnjsj,",
            "   IFNULL( DATE_FORMAT(t.`yjxcqnjsj`, '%Y/%m/%d' ),'-')AS yjxcqnjsj,",
            "   IFNULL( DATE_FORMAT(t.`bnjsj`, '%Y/%m/%d'),'-')  AS bnjsj,",
            "   IFNULL( DATE_FORMAT(t.`yjxcbnjsj`, '%Y/%m/%d' ),'-')AS yjxcbnjsj,",
            "   IFNULL( DATE_FORMAT(t.`xjsj`, '%Y/%m/%d') ,'-')  AS xjsj,",
            "   IFNULL( DATE_FORMAT(t.`yjxcxjsj`, '%Y/%m/%d'  ),'-')AS yjxcxjsj, ",
            "  f.`remark` ",
            "FROM",
            "  tb_fan f ",
            "  INNER JOIN tb_project p ",
            "    ON f.`attr_project_id` = p.id ",
            "  INNER JOIN `tb_fans_testingtime` t ",
            "    ON f.id = t.`fanid` ",

            " where f.create_user_id = #{uid} ",
            "<if test='fjbh != null and  fjbh !=  \"\" '>",
            " and f.`fcode` = #{fjbh}",
            "</if>",

            "<if test='projectid != null and  projectid !=  \"\" '>",
            " and p.`id` = #{projectid}",
            "</if>",

            "<if test='btime != null and  btime !=  \"\" '>",
            " and  LEFT(t.`create_time`,8) <![CDATA[ >= ]]> #{btime}",
            "</if>",


            "<if test='etime != null and  etime !=  \"\" '>",
            " and   LEFT(t.`create_time`,8) <![CDATA[ <= ]]> #{etime}",
            "</if>",

            " ORDER BY CAST( SUBSTR( f.fcode, '1', LOCATE('#', f.fcode) - 1 ) AS SIGNED) ",
            "</script>"})
        //主页查询全部风机数据
    List<LinkedHashMap> queryFansForDownExcel(@Param("fjbh") String fjbh,
                                              @Param("projectid") String projectid,
                                              @Param("btime") String btime,
                                              @Param("etime") String etime,
                                              @Param("uid") String uid);


}
